<!DOCTYPE html>
<html>
<head>
	<title>没想到你是这样的宝宝</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta charset="utf-8" />
	<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" />
	<meta content="yes" name="apple-mobile-web-app-capable" />
	<meta content="black" name="apple-mobile-web-app-status-bar-style">
	<meta content="telephone=no" name="format-detection" />
	<meta content="emai=no" name="format-detection" />
	<script src="/assets/zepto-1.1.6.js"></script>
	<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
</head>
<body style="margin:0">
	<div class="c">
		<input type="hidden" id="audio" value="">
		<input type="hidden" id="server_id" value="">
		<h1><button type="button" id="1">开始录音</button></h1>
		<h1><button type="button" id="2">停止录音接口</button></h1>
		<h1><button type="button" id="3">播放语音接口</button></h1>
		<h1><button type="button" id="4">停止播放接口</button></h1>
		<h1><button type="button" id="5">停止播放接口</button></h1>
		<h1><button type="button" id="6">停止播放接口</button></h1>
	</div>
	
	<script type="text/javascript">
    Zepto(function ($) {
        wx.config({
            debug: true,
            appId: '<?php echo $js_config['appId']?>',
            timestamp: <?php echo $js_config['timestamp']?>,
            nonceStr: '<?php echo $js_config['noncestr']?>',
            signature: '<?php echo $js_config['signature']?>',
            jsApiList: [
            	'startRecord',
            	'stopRecord',
            	'playVoice',
            	'stopVoice',
            	'uploadVoice',
            	'downloadVoice'
            ]
        });
        wx.ready(function () {
        	
        });

		$("#1").click(function(){
			wx.startRecord();
		});
		
		$("#2").click(function(){
			wx.stopRecord({
			    success: function (res) {
			        var localId = res.localId;
			        $("#audio").val(localId);
			    }
			});
		});
		
		$("#3").click(function(){
			wx.playVoice({
			    localId: $("#audio").val() // 需要播放的音频的本地ID，由stopRecord接口获得
			});
		});
		
		$("#4").click(function(){
			wx.stopVoice({
			    localId: $("#audio").val() // 需要停止的音频的本地ID，由stopRecord接口获得
			});
		});

		$("#5").click(function(){
			wx.uploadVoice({
			    localId: $("#audio").val(), // 需要上传的音频的本地ID，由stopRecord接口获得
			    isShowProgressTips: 1, // 默认为1，显示进度提示
			        success: function (res) {
			        var serverId = res.serverId; // 返回音频的服务器端ID
			        $("#server_id").val(serverId);
			    }
			});
		});

		$("#6").click(function(){
			wx.downloadVoice({
			    serverId: $("#server_id").val(), // 需要下载的音频的服务器端ID，由uploadVoice接口获得
			    isShowProgressTips: 1, // 默认为1，显示进度提示
			    success: function (res) {
			        var localId = res.localId; // 返回音频的本地ID
			        alert("音频ID:" + localId);
			    }
			});
		});
		
        
    })
	</script>
</body>
</html>